package com.zhengsr.latte.ec.ec.lunch;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.zhengsr.latte.ec.R;
import com.zhengsr.viewpagerlib.bean.PageBean;
import com.zhengsr.viewpagerlib.callback.PageHelperListener;
import com.zhengsr.viewpagerlib.indicator.TransIndicator;
import com.zhengsr.viewpagerlib.view.GlideViewPager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by zhengshaorui on 2018/4/21.
 */

public class SplashActivity extends BaseLunchActivity {
    private final List<Integer> IMAGES = new ArrayList<>(
            Arrays.asList(R.mipmap.guiding_1,R.mipmap.guiding_2,
                    R.mipmap.guiding_3,R.mipmap.guiding_4)
    );


    @Override
    public Object getLayout() {
        return R.layout.splash_actiity;
    }

    @Override
    public void initView(@Nullable Bundle savedInstanceState, View view) {
        initData(view);
    }

    private void initData(View view) {
        GlideViewPager viewPager = view.findViewById(R.id.splase_viewpager);
        TransIndicator indicator = view.findViewById(R.id.splase_indicator);
        Button button = view.findViewById(R.id.splase_start_btn);

        PageBean bean = new PageBean.Builder<Integer>()
                .setDataObjects(IMAGES)
                .setIndicator(indicator)
                .setOpenView(button)
                .builder();

        viewPager.setPageListener(bean, R.layout.splase_image_layout, new PageHelperListener() {
            @Override
            public void getItemView(View view, Object data) {
                ImageView imageView = view.findViewById(R.id.splase_image);
                imageView.setBackgroundResource((Integer) data);
            }
        });

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //点击的时候，我们检测是否用户登录过了
                checkUserSignIn();
            }
        });

    }

}
